<?php
session_start();

$con=mysql_connect("localhost","root","");
mysql_select_db("linhkienmt",$con);
?>
<html>

<head>
    <title>THẾ GIỚI LINH KIỆN MÁY TÍNH-XUÂN TUẤN</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
<link href="file:///D|/New Folder (2)/css/mau.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.dm {
     font-size:18px;
	 background-image:url(file:///D|/New Folder (2)/anh/nut/nut.jpg);
	 color:#FFCC33;
	 font-weight:bold;
	 }
.con {
       
       background:#00CCFF;
	   font-size:18px;
	   }
div#menut
    { margin-top:1px;
	  margin-left:1px;
	  line-height:1.5em;
	  width:162px;
	  	  }
* {margin:0;
   padding:0;
   }
    div#menut ul li:hover { 
							
	                          width:160px;}

  
 div#menut ul li
                { position:relative;
				border-bottom:1px solid #bccdd8;
				border-top:1px solid #bccdd8;
				border-left:1px solid #bccdd8;
				border-right:1px solid #bccdd8;
				background-image:url(file:///D|/New Folder (2)/anh/nut/menu_bg.jpg);
			
				}
div#menut ul li a {
					color:#FFFFFF;
                   text-decoration:none;
				   padding:5px;
				   }
	 

div#menut ul { list-style:none;
              border:1px solid #bcbd8;
			  }
div#menut ul li a:hover
                 { text-decoration:underline;
				 }
div#menut ul li ul { position:absolute;
                      top:1px;
					  left:160px;
					  display:none;
					  }
div#menut ul li:hover ul
                     { display:block;
					   width:160px;
					   }
.style3 {
	color: #FF0066;
	font-weight: bold;
}
.style4 {color: #66FF00}
.style5 {
	color: #000099;
	font-weight: bold;
}
			  
-->
</style>
</head>
<body>
        <tr>
		<td><center><table align="center" cellpadding="0" cellspacing="0" width="520" background="file:///D|/New Folder (2)/hinh anh/bg11.gif"><tr>
		  <td><TABLE cellSpacing=0 cellPadding=0 width=520 
                        align=center background="file:///D|/New Folder (2)/hinh anh/bg11.gif">
            <TBODY background="hinh anh/bg11.gif">
              <TR>
               
                <TD><H2 class="dm"><center>THÔNG TIN VỀ CÁC SẢN PHẨM</center></H2></TD>
              </TR>
              <TR>
                <TD 
                            style="BORDER-RIGHT: #009900 1px solid; BORDER-TOP: #009900 1px solid; BORDER-LEFT: #009900 1px solid; BORDER-BOTTOM: #009900 1px solid" 
                            colSpan=4>
                
                  <p>
				 
                  <?php
class pager
{
	function findstart($limit)
	{
		if((!isset($_GET['page']))||($_GET['page']=="1"))
		{
			$start=0;
			$_GET['page']=1;
		}
		else
		{
			$start=($_GET['page']-1)*$limit;
		}
		return $start;
	}
	
	function findpages($count,$limit)
	{
		$pages=(($count%$limit)==0) ? $count/$limit: floor($count/$limit)+1;
		return $pages;
	}
	
	function pagelist($curpage,$pages)
	{
		$page_list="";
		if(($curpage!=1)&&($curpage))
		{
			$page_list.="  <a href=\"".$_SERVER['PHP_SELF']."?page=1\" title=\"Trang đầu\"><<</a> ";
		}	
		if (($curpage-1)>0)
		{
			$page_list.="  <a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage-1)."\" title=\"Về trang trước\"><</a> ";
		}			
		for ($i=1;$i<=$pages;$i++)
		{
			if($i==$curpage)
			{
				$page_list.="<b>".$i."</b>";
			}
			else
			{
				$page_list.="  <a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\" title=\"Trang ".$i."\">".$i."</a> ";
			}
			$page_list.="";
		}
		if (($curpage+1)<=$pages)
		{
			$page_list.="  <a href=\"".$_SERVER['PHP_SELF']."?page=".$pages."\" title=\"Trang cuối\">>></a> ";
		}
		$page_list.="<td>\n";
		return $page_list;
	}
	
	function nextprev($curpage,$page)
	{
		$next_prev="";
		if(($curpage-1)<=0)
		{
			$next_prev.="Về trang trước";
		}
		else
		{
			$next_prev.="  <a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage-1)."\">Về trang trước </a> ";
		}
		$next_prev.=" | ";
		if (($curpage+1)>$pages)
		{
			$next_prev.="Đến trang sau";
		}
		else
		{
			$next_prev.="  <a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage+1)."\">Đến trang sau </a> ";
		}
		return $next_prev;
	}	
}
?>
                 
                    <?php
$con=mysql_connect("localhost","root","");
if (!$con)
 {
  echo "Khong the ket noi duoc";
  exit;
 }
 mysql_select_db("linhkienmt",$con);
 	$p= new pager;
 	$limit=6;
 	$start=$p->findstart($limit);
 	$count=mysql_num_rows(mysql_query("select * from sp"));
 	$pages=$p->findpages($count,$limit);
 	$result=mysql_query("select * from sp where maloai='MH'");
 if(mysql_num_rows($result)<>0)
 {
 	
	echo "<table align='center' width='500' cellpadding='0' cellspacing='0' class='style59' border='0'>";

$stt=0;
	while ($row=mysql_fetch_array($result))
	{
		$masp=$row[0];
		$tensp=$row[1];
		$maloai=$row[2];
		$mancc=$row[3];
		$dongia=$row[7];
		$dvtinh=$row[5];
		$soluong=$row[6];
		$mota=$row[8];
		$hinhanh=$row[4];
		$hinhanh="<img src='$hinhanh' width='100' height='100'>";
		if($stt%3==0)
		{
		echo"<table border=0 align='center'>";
		echo "<tr>";}
		echo "<td valign='top'>";
		echo "<table align='center'>";
		echo "<tr><td align='center'><b>$tenh</b></a></td></tr>";
		echo "<tr><td align='center' valign='middle'>$hinhanh</td></tr>";
		echo "<tr><td> số lượng:$soluong ($dvtinh)- Đơn giá:$dongia VNĐ</td></tr>";
		if ($soluong==0)
		{
				echo "<tr><td align='center'><font color='red'>Hết hàng</td></tr>";
				echo "<tr><td></td></tr>";
				echo "<tr><td align='center'><a href='chitiet.php?masp=".$masp."'>Chi tiết hàng </a>|<font color='green'> Đặt hàng";
		}
		else
		{
				echo "<tr><td align='center'><font color='green'>Số luong: $soluong</td></tr>";
				echo "<tr><td></td></tr>";
				echo "<tr><td align='center'><a href='chitiet.php?masp=".$masp."'>Chi tiết hàng </a>| <a href='giohang.php?id=".$masp."'>Đặt hàng</a>";
		}
		
		echo "<tr><td>&nbsp;</td></tr>";
		echo "</table>";
		echo "</td>";
		$stt=$stt+1;
		if($stt%3==0)
		{
		echo "<tr>";}
	}
		echo "</table>";
	}
	$pagelist=$p->pagelist($_GET['page'],$pages);
		echo "<p align='center'>";
		echo $pagelist;
		echo "</p>";
?>   
				 </p></TD>
              </TR>
	</tr>
</table>
</body>

<!-- Mirrored from www.suaonline.com.vn/?HOME/VN/ by HTTrack Website Copier/3.x [XR&CO'2010], Tue, 21 Dec 2010 13:15:47 GMT -->
</html>
